package com.app.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.app.biz.AppCategoryBiz;
import com.app.biz.AppInfoBiz;
import com.app.biz.AppVersionBiz;
import com.app.entity.AppInfo;
import com.app.entity.AppVersion;

@Controller
public class CheckAppController {
	@Autowired
	private AppCategoryBiz appCategoryBiz;
	@Autowired
	private AppVersionBiz appVersionBiz;
	@Autowired
	private AppInfoBiz appInfoBiz;
	
	@RequestMapping("checkAppById")
	public String checkAppById(Model model,Integer id){
		List<AppInfo> AppListById = appInfoBiz.getAppInfo(id);
		for(AppInfo appInfo:AppListById){
			System.out.println(appInfo.getLogoPicPath());
		}
		model.addAttribute("AppListById", AppListById);//查找根据id查看app信息
		
		List<AppVersion> appVersionList = appVersionBiz.getAllAppVersions(id);
		model.addAttribute("appVersionList", appVersionList);//查找根据id查看app信息
		return "checkAppById";
	}
	//删除AppInfo信息及版本信息
	@RequestMapping("deleteAppInfo")
	public String deleteAppInfo(Integer id){
		appInfoBiz.deleteAppInfo(id);
		appVersionBiz.deleteAppVersion(id);
		return "redirect:information";
	}
	

}
